package com.example.program.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.program.R;
import com.example.program.bean.PassBean;

import java.util.ArrayList;

import cn.carbs.android.avatarimageview.library.AvatarImageView;

/**
 * Created by mlzxg on 2016/12/20.
 */

public class PassAdapter extends BaseAdapter {

	private ArrayList<PassBean> Pbean;
	private Context mCon;

	public PassAdapter(Context con, ArrayList<PassBean> bean) {

		this.mCon = con;
		this.Pbean = bean;
	}

	@Override

	public int getCount() {
		return Pbean.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View tmp = null;
		PassBean now = Pbean.get(position);
		if (convertView == null) {
			tmp = View.inflate(mCon, R.layout.litem_view, null);
		} else {
			tmp = convertView;
		}
		//-----------------------------------------------
		AvatarImageView item_avatar = (AvatarImageView) tmp.findViewById(R.id.lv_avatar);
		TextView lv_Site = (TextView) tmp.findViewById(R.id.lv_Site);
		TextView lv_account = (TextView) tmp.findViewById(R.id.lv_account);
		TextView lv_des = (TextView) tmp.findViewById(R.id.lv_des);
		//-----------------------------------------------
		lv_Site.setText(now.Site);
		lv_account.setText(now.Account);
		lv_des.setText(now.description);
		item_avatar.setTextAndColorSeed(now.Site.substring(0, 1), now.Site);
		return tmp;
	}

}
